# 导入内置模块
import smtplib
from email.mime.text import MIMEText
from email.utils import  formataddr

class Email():
    def __init__(self, send_message):
        self.email_from = 'wyl350@126.com'
        self.send_message = send_message

        content,address,subject  = send_message

        content = send_message[content]
        address = send_message[address]
        subject = send_message[subject]

        msg = MIMEText(content,'html','utf-8')
        msg['From'] = formataddr(['王艳雷',self.email_from])
        msg['to'] = address
        msg['Subject'] = subject

        server = smtplib.SMTP_SSL('smtp.126.com')
        server.login(self.email_from,'VRPSTIZRBCKNCMDT')

        server.sendmail(self.email_from, 'wyl350@126.com',msg.as_string())
        server.quit()

Email({
    'content':'领导早上好，领导今天辛苦了。',
    'address':'wyl350@126.com',
    'subject':'一封测试邮件',
})

